<script>
function check_f(){
	
	alert('hello')
}
function get(branch, code, quantity){
	$.post("<?= site_url('product/transfer/check_branch_product')?>",{ branch:branch, code:code , quantity:quantity }, function(msg){
	if(msg==1){
	$.post("<?= site_url('product/transfer/get_destination_branch')?>",{ branch:branch }, function(msg1){
	if(msg1){
				jQuery('#areas').empty().append(msg1);
				jQuery('#areas').trigger("liszt:updated");
			//document.getElementById("areas").innerHTML = msg;	

		}
	});
	}else if(msg==2){
		alert('Required Quantity Not Available!!')
	}else if(msg==3){
		alert('Required Product is Not Available!!')
		
	}
	
	
	})

}

</script>

<h1>Create Branch</h1>
<p align="justify">Please enter the Branch information below.</p>

<div id="infoMessage"><?php echo $message;?></div>

<?php echo form_open("product/transfer/trasfer_product");?>
<form action="<?php echo site_url('product/transfer/trasfer_product');?>" method="POST" onsubmit="return false">
     <table width="60%" align="center" class="table-condensed">  
        <tr>
        	<td><strong>  Product Code:</strong> </td>
         	 <td>   <?php 
	 	$bl[0] = "";
	   		foreach($products as $product){
				$bl[$product->id] = $product->code;
			}
			echo form_dropdown('product_code', $bl, '', 'class="chzn-select" id="product_code" data-placeholder="Choose a Product Code" style="width:220px;"');  ?>
	</td>
        </tr>
		<tr>
        	<td>&nbsp;</td>
			<td>&nbsp;</td>	
        </tr>
		<tr>
        	<td><strong> Quantity:</strong></td>
			<td><?php echo form_input($quantity);?></td>	
        </tr>
	
		<tr>
         	<td><strong>Source Branch: </strong></td>
         	<td><select name="source_branch" onchange="get(this.value,$('#product_code').val(),$('#quantity').val());" class="span6 chzn-select">
    			<option value="">-- Select-- </option>
				<option value="0"> Warehouse </option>
			    <?php foreach ($branches as $branch) {?>
			    <option value="<?=$branch->id?>" <?php 
				if(isset($edit)) {
				if($edit['user_id'] == $branch->id)
				{
					echo 'selected = "selected"';
				}
				}
				else {
					echo set_select('id_branch',$branch->id);
				}
				?> ><?= $branch->name;?></option >
   				 <?php } ?>
    		</select>
		</td>
        </tr>
        
     <tr>
     <td><strong>Destination Branch:</strong> </td>
      <td><select id="areas" name="destination_branch" class="span6 chzn-select" onchange="get_amount(this.value);">
	</select>
	</td>
       </tr>
		<tr>
        	<td><strong> Date:</strong></td>
			<td><?php echo form_input($date);?></td>	
        </tr>

<tr>
<td>&nbsp;</td>	<td><input type="submit" value="Submit" onclick="return check_f"></td>
</tr> 
</table>
<?php echo form_close();?>
